﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using hospital_registration_system.BLL;
using hospital_registration_system.Entity;

namespace hospital_registration_system.Utility
{
    public class ManagerIllness
    {
        /// <summary>
        /// 所有疾病管理功能的类
        /// </summary>
        protected static IllnessService service = new IllnessService();

            /// <summary>
            /// 查询所有的疾病
            /// </summary>
            /// <returns>返回疾病的信息链表</returns>
            public static List<Illness> getAllIllness()
            {
                return service.selectAllIllness();
            }

            /// <summary>
            /// 删除指定id的疾病
            /// </summary>
            /// <param name="id">要删除的疾病id</param>
            /// <returns>返回操作提示信息</returns>
            public static string deleteIllnessById(int id)
            {
                if (service.deleteIllnessById(id))
                {
                    return "删除成功";
                }
                else
                {
                    return "删除失败";
                }
            }

        /// <summary>
        /// 修改疾病信息
        /// </summary>
        /// <param name="illness"></param>
        /// <returns></returns>
        public static string updateIllness(Illness illness)
            {
                if (service.updateIllness(illness))
                {
                    return "修改成功";
                }
                else
                {
                    return "修改失败";
                }
            }

        /// <summary>
        /// 插入一条只有疾病名的疾病信息
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static string insertIllness(string name)
        {
            if (service.insertIllness(name))
            {
                return "插入成功";
            }
            else
            {
                return "插入失败";
            }
        }

        /// <summary>
        /// 添加疾病与科室之间的联系
        /// </summary>
        /// <returns></returns>
        public static string addIllAndDep(int illId,int depId)
        {
            if (service.illnessAndDepartment(illId, depId))
            {
                return "插入成功";
            }
            else
            {
                return "插入失败";
            }
        }

        /// <summary>
        /// 根据疾病的id查询相关科室
        /// </summary>
        /// <param name="illId"></param>
        /// <returns></returns>
        public static List<Illness_departments> findIllness_departmentsByIllsId(int illId)
        {
            return service.selectIllDepByIllId(illId);
        }

        /// <summary>
        /// 删除疾病与科室表的联系
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static string deleteIllness_departments(int id)
        {
            if (service.deleteIll_depById(id))
            {
                return "成功";
            }
            else
            {
                return "失败";
            }
        }
    }
}
